//
//  PopMoreViewController.m
//  SugarPile
//
//  Created by Charlie. on 16/1/28.
//  Copyright © 2016年 www.lanou39.蓝鸥科技. All rights reserved.
//

#import "PopMoreViewController.h"
#import "LCPrefixHeader.pch"
#import "PopMoreModel.h"
#import "PopMoreTableViewCell.h"
@interface PopMoreViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) UITableView *tableView; /**<更多*/
@property (nonatomic, retain) NSMutableArray *dataArr; /**<数据*/
@end

@implementation PopMoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.dataArr = [NSMutableArray array];
    // TableView
    [self createtableView];
    
    // 数据处理
    [self dataArrHandle];
}
- (void)createtableView
{
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    [self.tableView release];
    [_tableView registerClass:[PopMoreTableViewCell class] forCellReuseIdentifier:@"cell"];

}
- (void)dataArrHandle
{
    
    NSString *str = @"http://203.80.144.213/napi/ad/banner/list/?platform_version=4.4.4&device_platform=HM%2B2A&__dtac=%257B%2522_r%2522%253A%2520%2522495019%2522%257D&screen_width=720&screen_height=1280&__domain=www.duitang.com&app_version=68&start=0&query_type=normal&platform_name=Android&locale=zh&ad_id=ANA004&limit=12&app_code=nayutas";
    [LCAFNetWorking GETWithURL:str completion:^(id result) {
        
        NSArray *arr = [PopMoreModel modelHanderWithArray:result[@"data"][@"object_list"]];
        ;
        for (PopMoreModel *m in arr) {
            [self.dataArr addObject:m];
        }
        
        
        [_tableView reloadData];
    }];
}

#pragma mark - tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//    for (NSInteger i = 0; i < 3; i++) {
//        [self.dataArr addObject:self.dataArr[i]];
//        [self.dataArr removeObjectAtIndex:0];
//    }
    return _dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    PopMoreTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    if (_dataArr.count != 0) {
        
        PopMoreModel *m = _dataArr[indexPath.row];
        
        cell.model = m;
    }
    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 70;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
